/* 
 */
#include<tuple>
#include<numeric>
#include<iostream>
#include<bits/stdc++.h>
namespace grm {
  /**
   * @brief For gcd, the C++ 17 have standardized the functionso just use that. No thanks. 
   * @tparam T 
   * @param a 
   * @param b 
   * @return T 
   */
  template<typename T>
  T gcd(T a, T b) {
    return b==0?a:gcd(b, a%b);
  }

  /**
   * @brief Extended Euclid's Algorithm: ax+by=gcd(a, b)
   * 
   * @param a 
   * @param b 
   * @return std::tuple<int, int, int> 
   */
  std::tuple<int, int, int> extgcd(int a, int b) {
    if(b==0) {
      return {1, 0, a};
    }
    else {
      int x, y, g;
      std::tie(x, y, g) = extgcd(b, a%b);
      return {y, x-(a/b)*y, g};
    }
  }
}

int main() {
  using namespace std;
  int a=30, b=12;
  int x, y, g;
  tie(x, y, g) = grm::extgcd(a, b);
  printf("%d %d %d\n",x, y, g);  // 1 -2 6